﻿<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>加盟教练</title>
    <link rel="stylesheet" href="css/amazeui.css">
    <link href="css/amazeui.datetimepicker.css" rel="stylesheet" />
    <script src="js/vue.js"></script>
    <script src="js/jquery-3.2.1.min.js"></script>
    <script src="js/common.js"></script>
    <script src="http://file.jiaoxin-tech.cn/help/js/upyun.js"></script>
    <meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1, user-scalable=no">
    <style>
        * {
            padding: 0;
            border: 0;
            margin: 0;
        }

        .veads1_i1 {
            display: block;
            float: left;
            margin-top: 2%;
            width: 2.5%;
        }

        .veads1_s1 {
            display: block;
            text-align: center;
            font-size: 1.8rem;
        }
    </style>
</head>
<body>
    <div id="page1" v-cloak>
        <header data-am-widget="header" class="am-header am-header-default" style="background-color: #FFFFFF; border-bottom: 1px solid rgb(211, 211, 211); ">
            <div class="am-header-left am-header-nav" onclick="goBack()">
                <a href="javascript:" class="">
                    <img class="am-header-icon-custom" src="images/veas07.png" alt="" />
                </a>
            </div>
            <h4 class="am-header-title" style=" color: black;">加盟教练</h4>
            <div class="am-header-right am-header-nav"><a href="/Wap/Index.html" class="am-header-icon am-icon-home" style="color: #A9A9A9; "></a></div>
        </header>
        <div class="am-form" data-am-validator>
            <fieldset>

                <div class="am-form-group">
                    <label for="doc-ipt-name-1">姓名<span style="color:red;">*</span></label>
                    <input type="text" class="" v-model="Name" id="doc-ipt-name-1" placeholder="请输入您的姓名">
                </div>
                <div class="am-form-group">
                    <label for="doc-ipt-tel-1">电话<span style="color:red;">*</span></label>
                    <input type="tel" class="" v-model="Phone" id="doc-ipt-tel-1" placeholder="输入电话">
                </div>
                <div class="am-form-group">
                    <label for="doc-select1-1">选择加盟项目<span style="color:red;">*</span></label>
                    <select id="doc-select1-1" v-on:change="classtypeIdSelect($event)">
                        <!--<option v-bind:value="0">加盟平台教练</option>-->
                        <option v-for="item in classtype" v-bind:value="item.Id">{{item.Name}}</option>
                    </select>
                    <span class="am-form-caret"></span>
                </div>
                <div class="am-form-group">
                    <label for="doc-select-1">选择加盟平台<span style="color:red;">*</span></label>
                    <select id="doc-select-1" v-on:change="indexSelect($event)">
                        <!--<option v-bind:value="0">加盟平台教练</option>-->
                        <option v-for="item in venueinfo" v-bind:value="item.Id">{{item.Name}}</option>
                    </select>
                    <span class="am-form-caret"></span>
                </div>

                <!--<div class="am-u-sm-12" style="position: relative; padding-bottom:2px;">
                <input type="text" readonly name="faceImg" datatype="*" nullmsg="请上传照片" style='color: #969696; padding-left:2%;padding-top:1%;resize: none;height: 3rem;width: 50%;display: block; border: 1px solid #ededed;border-radius: 10px; ' placeholder="上传您的照片" v-model="faceImg" />
                <input type="button" id="uploadButton" class="btn btn-success" value="点击上传" />
            </div>-->
                <div class="am-form-group">
                    <label for="doc-ipt-file-1">点击上传照片<span style="color:red;">*</span></label>
                    <input type="hidden" readonly  v-model="faceImg" name="faceImg">

                    <label >
                        <input type="file" id="doc-ipt-file-1" onchange="upload()" multiple name="file" class="am-btn am-btn-default am-btn-sm" style="display:none">
                        <img v-bind:src="faceImg.length>0 ? faceImg : 'images/nouserfaceimg.png'" style="width:50px;height:50px;" />
                    </label>
                </div>
                <!--<div class="am-form-group am-form-file">
                    <label for="file">上传您的照片</label>
                        <input type="file" id="file" onchange="upload()" multiple name="file" class="am-btn am-btn-default am-btn-sm" />
                        <input type="button" id="uploadButton" class="am-btn am-btn-default am-btn-sm" value="选择要上传的照片" />
                        <input type="text" readonly id="uploadButton" v-model="faceImg" name="faceImg">
                </div>-->
                <div class="am-form-group">
                    <label for="doc-ipt-Birthday-1">出生日期<span style="color:red;">*</span></label>
                    <input type="text" class="am-form-field" v-model="Birthday" id="doc-ipt-Birthday-1" placeholder="输入出生日期" ><!--readonly required-->
                </div>
                <div class="am-form-group">
                    <label for="doc-ta-1">简介</label>
                    <textarea class="" rows="5" id="doc-ta-1" v-model="profile" placeholder="请输入您的简介"></textarea>
                </div>
            </fieldset>
        </div>
        <button type="button" class="am-btn am-btn-default am-radius" style="width: 90%;display: block;margin: 0 auto;background: #23c788;color: #fff;border-radius: 5px" v-on:click="tijiao()">提交</button>
    </div>
</body>
<script src="js/zishiying.js"></script>
<script src="js/amazeui.datetimepicker.min.js"></script>
<script src="js/amazeui.datetimepicker.zh-CN.js"></script>
<script>
    var page = new Vue({
        el: '#page1',
        data: {
            Name: '',
            Phone:"",
            faceImg: "",
            Birthday: "",
            indexId: "0",
            profile:"",
            venueinfo: [],
            classtype: [],
            classtypeId:"0",
            count: 200
        },
        methods: {
            getvenueinfo: function () {
                var that = this;
                $.ajax({
                    type: 'GET',
                    url: apiUrl + '/Api/Mine/GetVenueList',
                    success: function (data) {
                        //console.log(data);
                        if (data.errcode == 0) {
                            that.venueinfo = data.data.venueList;
                            that.indexId = data.data.venueList[0].Id;
                            that.classtype = data.data.ClassType;
                            that.classtypeId = data.data.ClassType[0].Id;
                            console.log(that.indexId);
                        } else {
                            alert(data.errmsg);
                        }
                    },
                    //error: function () {
                    //    alert("服务器加载异常");
                    //}
                })
            },
            indexSelect: function (event) {
                this.indexId = event.target.value;
            },
            classtypeIdSelect: function (event) {
                this.classtypeId = event.target.value;
            },
            tijiao: function () {
                var that = this;
                $.ajax({
                    type: 'POST',
                    url: apiUrl + '/Api/Mine/JoinCoach',
                    data: { Name: that.Name, faceImg: that.faceImg, Birthday: that.Birthday, venuegId: that.indexId, classtypeId: that.classtypeId, profile: that.profile, Phone: that.Phone },
                    success: function (data) {
                        console.log(data);
                        if (data.errcode == 0) {
                            alert(data.errmsg, function () {
                                location.href = "usercenter.html";
                            });
                            //console.log(that.userinfo)
                        } else {
                            alert(data.errmsg);
                        }
                    },
                    //error: function () {
                    //    alert("服务器加载异常");
                    //}
                })
            }
        }
    })
    $(function () {
        page.getvenueinfo();
    })

</script>

<script type="text/javascript">
    $(function () {
        $('#doc-ipt-Birthday-1').datetimepicker({
            format: "yyyy-mm-dd",
            startView: 2,
            minView: 2,
            language: 'zh-CN',
            todayHighlight: false,
            autoclose:true
        }).change(function () {
            page.Birthday = $('#doc-ipt-Birthday-1').val();
        });
    });
</script>
<script type="text/javascript">
    var filebase = "http://file.jiaoxin-tech.cn";
    var upyun = new Upyun({
        bucket: 'topman-upyun',//'topman-upyun',
        operator: 'admin',
        getSignatureUrl: 'https://xcx.egaopa.com/Api/upyun/index',
        opts: {
            'notify-url': 'http://feiyu.test.jiaoxin-tech.cn/Api/test/upyun',
            //'x-gmkerl-thumb':'/quality/75',//压缩,只能上传图片类型
            //'content-secret':'zhangsan',//文件密钥，用于保护文件，防止文件被直接访问
            //'allow-file-type':'jpg,jpeg,png',//允许上传的文件扩展名，以 , 分隔
            //'content-length-range':'',//文件大小限制，格式：min,max，单位：字节 如 102400,1024000，表示允许上传 100Kb～1Mb 的文件
            //'ext-param':'',//自定义参数,回调时带回
            //'b64encoded':'on',//base64解码
        }
    })


    function upload() {
        if (document.getElementById("doc-ipt-file-1").files.length > 0) {
            for (var n = 0; n < document.getElementById("doc-ipt-file-1").files.length; n++) {
                upyun.upload({
                    localPath: document.getElementById("doc-ipt-file-1").files[n],
                    remotePath: '/feiyu/{filemd5}{.suffix}',
                    success: function (res) {
                        //document.getElementById("fileurl").setAttribute('href', filebase + res.url);
                        //document.getElementById("fileurl").innerHTML = filebase + res.url;
                        alert('上传成功');
                        page.faceImg = filebase + res.url;
                        console.log('上传成功:', res)
                    }, error: function (err) {
                        alert("上传失败:" + err.message);
                    }, complete: function (xhr) {
                        console.log("上传操作结束:", xhr);
                    }, progress: function (e) {
                        //document.getElementById("progress").innerHTML = parseInt(((e.loaded / e.total) || 0) * 100) + "%";
                        //document.getElementById("number").innerHTML = e.total < 1024 * 1024 ? ((e.loaded / 1024).toFixed(2) + "k/" + (e.total / 1024).toFixed(2) + "k") : ((e.loaded / (1024 * 1024)).toFixed(2) + "M/" + (e.total / (1024 * 1024)).toFixed(2) + "M");
                    }
                })
            }
        }
    }
</script>
</html>
